import time
import unittest

import app
from scropts.test01_login_demo import Test01LoginDemo
from scropts.test03_employee_demo import Test03EmployeeDemo
from scropts.test02_login_demo_param import Test01LoginDemoParam

# 封装测试套件
from tools.HTMLTestRunner import HTMLTestRunner


suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(Test01LoginDemoParam))

# 员工管理场景执行用例
suite.addTest(Test01LoginDemo("test01_login_d"))
suite.addTest(unittest.makeSuite(Test03EmployeeDemo))

# 指定测试报告生成的路径
report = app.BASE_DIR + "/report/report-{}.html".format(time.strftime("%Y%m%d - %H%M%S"))


# 文件流形式写入文件
with open(report, "wb") as f:
    # 创建HTMLTestRunner的运行器（参数1-》指定写入的文件）
    runner= HTMLTestRunner(f, title="接口测试报告")
    # 执行测试套件
    runner.run(suite)